<include file="common:__head__"/>
<style type="text/css">
    body,.page{
        background-color: #FFF;
    }
    .ftitle {
        font-size: 0;
        height: 24px;
        float: left;
    }
    .ftitle h3, .ftitle h5 {
        font-size: 12px;
        font-weight: normal;
        line-height: 24px;
        color: #777;
        vertical-align: bottom;
        letter-spacing: normal;
        display: inline-block;
        padding: 0;
    }
    .ftitle h3 {
        font-size: 16px;
        color: #333;
        margin-right: 6px;
    }
    .pReload {
        color: #999;
        background-color: #FFF;
        width: 24px;
        height: 24px;
        float: left;
        text-align: center;
        line-height: 24px;
        margin: 0 0 0 20px;
        position: relative;
        z-index: 1;
    }
    .pReload i {
        display: inline-block;
        font: normal normal normal 14px/1 FontAwesome;
        text-rendering: auto;
        -webkit-font-smoothing: antialiased;
        vertical-align: baseline;
        margin: 5px auto 0;
    }
    .fa-refresh:before {
        content: "\f021";
    }
    .pReload:hover {
        color: #333;
        background-color: #E6E6E6;
        border-radius: 5px;
        cursor: pointer;
    }
    .sDiv {
        float: right;
        position: relative;
        overflow: hidden;
    }
    .sDiv2 {
        margin-right: 10px;
        font-size: 0;
        display: inline-block;
        vertical-align: middle;
        border: solid 1px #D7D7D7;
        border-radius: 5px;
    }
    .sDiv2 .qsbox {
        background-color: #FFF;
        font-size: 12px;
        line-height: 24px;
        width: 140px;
        height: 24px;
        padding: 1px 5px;
        border: none;
        /*font-size: 12px;*/
        vertical-align: top;
        letter-spacing: normal;
        display: inline-block;
        border-radius: 0;
    }
    .sDiv2 .abtn {
        border: none;
        border-radius: 0;
        font-size: 12px;
        vertical-align: top;
        letter-spacing: normal;
        display: inline-block;
    }
    .sDiv2 .abtn {
        height: 26px;
        line-height:26px;
        cursor: pointer;
        border-left: solid 1px #D7D7D7;
    }
</style>
<div class="permissions-tabs">
    <a class="role tabs-bg" href="{:U('report/sales_profile')}">数据概况</a>
</div>
<div class="page" style="padding:15px;">
    <div class="add-msg">
        <div class="ftitle">
            <h3>销售概况</h3>
            <h5>今日销售总额：￥<empty name="today.today_amount">0<else/>{$today.today_amount}</empty>|
                人均客单价：￥{$today.sign}|今日订单数：{$today.today_order}|今日取消订单：{$today.cancel_order}</h5>
        </div>
        <div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div>
        <form class="navbar-form form-inline" id="search-form" method="get" action="" onSubmit="return check_form();">
            <input type="hidden" name="m" value="Seller"/>
            <input type="hidden" name="c" value="Report"/>
            <input type="hidden" name="a" value="sales_profile"/>
        <div class="sDiv">
            <div class="sDiv2" style="margin-right: 10px;">
                <input type="text" size="30" name="start_time" id="start_time" value="{$start_time}" placeholder="起始时间" class="qsbox" >
                <input type="button" class="abtn" value="起始时间">
            </div>
            <div class="sDiv2" style="margin-right: 10px;">
                <input type="text" size="30" name="end_time" id="end_time" value="{$end_time}" placeholder="截止时间" class="qsbox" >
                <input type="button" class="abtn" value="截止时间">
            </div>
            <div class="sDiv2">
                <input class="btn btn-blue" style="width: 44px;height:28px;" value="搜索" type="submit">
            </div>
        </div>
        </form>
    </div>

    <div id="statistics" style="height:400px;"></div>

    <div class="permissions-table">
        <table border="0" width="100%" class="keep_on">
            <thead>
            <tr>
                <td width="15%">时间</td>
                <td width="40%">订单数量</td>
                <td>销售总额</td>
                <td>客单价</td>
                <td>当天详情</td>
            </tr>
            </thead>
            <tbody class="ready">
            <foreach name="list" item="vo" key="k" >
                <tr>
                    <td>{$vo.day}</td>
                    <td>{$vo.order_num}</td>
                    <td>{$vo.sign}</td>
                    <td>{$vo.amount}</td>
                    <td>
                        <a class="btn btn-blue" href="{:U('Order/index',array('start_time'=>$vo['day'],'end_time'=>$vo['end'],'btn'=>'搜索','is_pay'=>'-2','status'=>'-2','is_deliver'=>'-2'))}">订单列表</a>
                    </td>
                </tr>
            </foreach>
            </tbody>
        </table>
        {$page}
    </div>
</div>
<script src="__PUBLIC__/plugins/layer/laydate/laydate.js"></script>
<script src="__PUBLIC__/seller/js/echarts.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/seller/js/macarons.js"></script>
<script src="__PUBLIC__/seller/js/china.js"></script>
<script type="text/javascript">
    var res = {$result};
    var myChart = echarts.init(document.getElementById('statistics'),'macarons');
    option = {
        tooltip : {
            trigger: 'axis'
        },
        toolbox: {
            show : true,
            feature : {
                mark : {show: true},
                dataView : {show: true, readOnly: false},
                magicType: {show: true, type: ['line', 'bar']},
                restore : {show: true},
                saveAsImage : {show: true}
            }
        },
        calculable : true,
        legend: {
            data:['交易金额','订单数','客单价']
        },
        xAxis : [
            {
                type : 'category',
                data : res.time
            }
        ],
        yAxis : [
            {
                type : 'value',
                name : '金额',
                axisLabel : {
                    formatter: '{value} ￥'
                }
            },
            {
                type : 'value',
                name : '客单价',
                axisLabel : {
                    formatter: '{value} ￥'
                }
            }
        ],
        series : [
            {
                name:'交易金额',
                type:'bar',
                data:res.amount
            },
            {
                name:'订单数',
                type:'bar',
                data:res.order
            },
            {
                name:'客单价',
                type:'line',
                yAxisIndex: 1,
                data:res.sign
            }
        ]
    };
    myChart.setOption(option);
    $(document).ready(function(){
        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function(){
            $(this).toggleClass('trSelected');
        });

        // 点击刷新数据
        $('.fa-refresh').click(function(){
            location.href = location.href;
        });

        $('#start_time').layDate();
        $('#end_time').layDate();
    });

    function check_form(){
        var start_time = $.trim($('#start_time').val());
        var end_time =  $.trim($('#end_time').val());

        var start_timestamp = Date.parse(new Date(start_time));
        start_timestamp = start_timestamp / 1000;

        var end_timestamp = Date.parse(new Date(end_time));
        end_timestamp = end_timestamp/1000;

        if(start_timestamp > end_timestamp){
            layer.msg("开始时间必须大于结束时间");return false;
        }
        if(start_time == '' ^ end_time == ''){
            layer.alert('请选择完整的时间间隔');
            return false;
        }
        return true;
    }
</script>
<include file="common:__foot__"/>